﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;

namespace ReportDesign
{
    public partial class ReportWithParameter : DevExpress.XtraReports.UI.XtraReport
    {
       
 #region inner classes
        class TableAdapterDataFiller1 : ITableReportDataFiller1 {
            public void Fill(ReportWithParameter report) {
                report.getCarsTableAdapter1.Fill(report.carWithParameters1.Cars, report.Category);
            }
        }        
        #endregion

        ITableReportDataFiller1 dataFiller;

        public ReportWithParameter() : this(new TableAdapterDataFiller1()) { }
        public ReportWithParameter(ITableReportDataFiller1 dataFiller)
        {
            InitializeComponent();
           // Name = ReportNames.TableReport;
           // DisplayName = ReportNames.TableReport;
            this.dataFiller = dataFiller;
            BeforePrint += Report_BeforePrint;
        }

        public String Category { get { return Parameters["parameter1"].Value.ToString(); } }

        void Report_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
            carWithParameters1.Clear();
            dataFiller.Fill(this);    
        }
    }

    public interface ITableReportDataFiller1 {
        void Fill(ReportWithParameter report);
    }
}
